<?php
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($_SERVER['DOCUMENT_ROOT']."/Modules/MF93FL27/modconf.mex");
MYTCONN();
if (!isset($_POST['n_rows'])) {	$_POST['n_rows'] = 10; }
?>
<table width="100%"  border="0" cellspacing="6" cellpadding="1">
  <tr>
    <td colspan="2"><div id="Bss_action"></div></td>
  </tr>
  <tr>
    <td width="35%">Brinde</td>
    <td>Fornecedor</td>
    <td>Data de Disponibilidade</td>
    <td>Quantidade</td>
    <td>Atribuído</td>
    <td>Estado</td>
  </tr>
  <?php for($i=1;$i<=$_POST['n_rows'];$i++) { ?>
  <tr>
    <td width="65%"><?php 
	mn_field('hidden','ED','row_number',$i,'','','','');
	$Qur = "SELECT REF AS ID, CONCAT(InternalRef,' ',NAME) AS NAME FROM bonusproducts ORDER BY InternalRef";
	mn_field('select','ED','bss_Product'.$i,'',$Qur,'- Escolher -','','');
	if($i==1) {
	mn_field('button','ED','set_prod',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_Product\'+$i).value=document.Bss_Multientry.bss_Product1.value;
		$i++;
		}');
	}
	echo '</td><td>';
	$Qur = "SELECT bpv_ID AS ID, bpv_Name AS NAME FROM bonusproviders";
	mn_field('select','ED','bss_Provider'.$i,'',$Qur,'- Escolher -','',''); 
	if($i==1) {
	mn_field('button','ED','set_prov',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_Provider\'+$i).value=document.Bss_Multientry.bss_Provider1.value;
		$i++;
		}');
	}	
	echo '</td><td>';
	mn_field('date','ED','bss_Time'.$i,'','Bss_Multientry','8','','');	
	if($i==1) {
	mn_field('button','ED','set_prod',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_Time\'+$i).value=document.Bss_Multientry.bss_Time1.value;
		$i++;
		}');
	}
	echo '</td><td>';
	mn_field('text','ED','bss_IniQuant'.$i,'0','6','6','','INPNUM');
	if($i==1) {
	mn_field('button','ED','set_prod',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_IniQuant\'+$i).value=document.Bss_Multientry.bss_IniQuant1.value;
		$i++;
		}');
	}	
	echo '</td><td>';
	$Qur = "SELECT office_number AS ID, CONCAT(office_number,' ',name) AS NAME FROM systemoffice.main_offices WHERE Type = 1";
	mn_field('select','ED','bss_Office'.$i,'',$Qur,'N/A','','');
	if($i==1) {
	mn_field('button','ED','set_prod',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_Office\'+$i).value=document.Bss_Multientry.bss_Office1.value;
		$i++;
		}');
	}
	echo '</td><td>';
	$Qur = "SELECT stt_Word AS NAME, sttFlag AS ID FROM hd_sysstatus WHERE stt_Sistema = 22 AND sttFlag IN (1,2,3,4)";
	mn_field('select','ED','bss_Status'.$i,3,$Qur,'','',''); 
	if($i==1) {
	mn_field('button','ED','set_prod',' = ','','','','" onclick="
		$i = 1;
		while($i<=document.Bss_Multientry.n_rows.value) {
		document.getElementById(\'bss_Status\'+$i).value=document.Bss_Multientry.bss_Status1.value;
		$i++;
		}');
	}
	echo '</td>
    </tr>';
   } ?>
 <tr>
    <td colspan="10"><?php mn_field('button','ED','bss_Save','Guardar','','','','" onclick="
		document.Bss_Multientry.action=\''.$MODURL.'lib/pr_multientry.php\';
		subform(\'Bss_Multientry\',\'Bss_Action\');'); ?></td>
  </tr>
</table>